import { ref } from 'vue'
export const getSkeletonInstance = (options) => {
	const defaultRepeat = 8
	const skeletonRepeat = ref(options && options.skeletonRepeat ?  options.skeletonRepeat : defaultRepeat)
  const skeletonLoading = ref(true)
	
	/**
	 * 隐藏骨架屏
	 */
	const hideSkeleton = () => {
		skeletonLoading.value = false
	}
	/**
	 * 重置骨架屏重复次数，用于获取数据后，渲染数据之前
	 */
	const narrowSkeleton = () => {
		skeletonRepeat.value = 1
	}
	return {
		skeletonRepeat,
		skeletonLoading,
		hideSkeleton,
		narrowSkeleton
	}
}